package com.example.weather_app.diary;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.weather_app.R;
import java.util.List;

public class ReminderListActivity extends AppCompatActivity {
    private RecyclerView recyclerView;
    private DiaryAdapter diaryAdapter;
    private DiaryDao diaryDao;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.reminder_list_activity);

        // 初始化组件
        recyclerView = findViewById(R.id.recyclerReminders);
        diaryDao = new DiaryDao(this);

        // 设置RecyclerView
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        diaryAdapter = new DiaryAdapter(this);
        recyclerView.setAdapter(diaryAdapter);

        // 加载设置了提醒的日记
        loadReminderDiaries();
    }

    // 加载设置了提醒的日记
// ReminderListActivity.java
    private void loadReminderDiaries() {
        Log.d("ReminderListActivity", "Loading reminder diaries");
        List<Diary> diaries = diaryDao.getReminderDiaries();
        Log.d("ReminderListActivity", "Number of reminder diaries loaded: " + diaries.size());
        diaryAdapter.setDiaries(diaries);
    }
}